package com.ktjy.test;

import com.ktjy.entity.Employee;
import com.ktjy.printer.Printer;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    @Test
    public void test1(){
        //1.获取spring上下文对象
        ApplicationContext context=
                new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        //2.获取对象
        Employee employee=(Employee)context.getBean("employee");
        Employee employee2=(Employee)context.getBean("employee2");

        //3.使用对象
        employee.introduce();
        employee2.introduce();
    }

    @Test
    public void test2(){
        //1.获取spring上下文对象
        ApplicationContext context=
                new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        //2.获取对象
        Employee employee3=(Employee)context.getBean("employee3");


        //3.使用对象
        employee3.introduce();
    }

    @Test
    public void test3(){
        //1.获取spring上下文对象
        ApplicationContext context=
                new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        //2.获取对象
        Printer printer=(Printer) context.getBean("printer");


        //3.使用对象
        String msg="收到含税单价圣诞节呃呃呃而疼痛天涯急" +
                "急急飞机好大呀依然扩大扩大时间段可视角度哭踢人推入颓然";
        printer.print(msg);
    }

    @Test
    public void test4(){
        //1.获取spring上下文对象
        ApplicationContext context=
                new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        //2.获取对象
        Printer printer=(Printer) context.getBean("printer4");


        //3.使用对象
        String msg="收到含税单价圣诞节呃呃呃而疼痛天涯急" +
                "急急飞机好大呀依然扩大扩大时间段可视角度哭踢人推入颓然";
        printer.print(msg);
    }
}
